package com.gitee.zycra.union.api.common.param;

import com.gitee.zycra.union.api.common.model.ApiProject;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;

/**
 * @author zycra
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
public class UpdateProjectParam {

    /**
     * 项目ID
     */
    @NotNull(message = "项目ID不能为空")
    private Long id;

    /**
     * 项目名
     */
    @NotNull(message = "项目名不能为空")
    private String projectName;

    /**
     * 工程名
     */
    @NotNull(message = "工程名不能为空")
    private String projectLabel;

    /**
     * 项目域名
     */
    @NotNull(message = "项目域名不能为空")
    private String projectHost;

    /**
     * 项目组ID
     */
    private Long groupId;

    public static ApiProject convertToApiProject(UpdateProjectParam updateProjectParam) {
        if (updateProjectParam == null) {
            return null;
        }
        return new ApiProject()
                .setId(updateProjectParam.getId())
                .setProjectName(updateProjectParam.getProjectName())
                .setProjectLabel(updateProjectParam.getProjectLabel())
                .setProjectHost(updateProjectParam.getProjectHost())
                .setGroupId(updateProjectParam.getGroupId());
    }
}
